#!/data/Software/mydan/perl/bin/perl -I/data/Software/mydan/CI/lib -I/data/Software/mydan/CI/private/lib
use strict;
use warnings;
use FindBin qw( $RealBin );
use POSIX;
use Util;
use Logs;
use File::Basename;

$| ++;

=head1 SYNOPSIS

    db => $mysql,

=cut

return sub
{
    my %param = @_;

    my ( $myname, $db, $logs ) = ( Util::myname(), $param{db}, $param{logs} );

    my $logs = Logs->new( 'clean.clean_logs_build_temp_uuid' ) unless $logs;

    my $expire = time - 86400;
    for my $path ( glob "$RealBin/../logs/build_temp_uuid/*" )
    {
        my $uuid = basename $path;
        next unless $uuid =~ /^[a-zA-Z0-9]{12}$/;
        my $mtime = ( stat $path )[9];
        next unless $mtime && $mtime < $expire;
        $logs->say( "clean $uuid" );
        system "rm -rf '$path'";


    }


}
